package com.bjpowernode.rbac.mapper;

import com.bjpowernode.rbac.entity.Customer;
import com.bjpowernode.rbac.query.CustomerQuery;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Repository
public interface CustomerMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Customer record);

    int insertSelective(Customer record);

    Customer selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Customer record);

    int updateByPrimaryKey(Customer record);

    List<Customer> selectByCondition(CustomerQuery customerQuery);

    List<Customer> selectPotentialCustomerByCondition(CustomerQuery customerQuery);

    List<Customer> selectCustomerPoolByCondition(CustomerQuery customerQuery);

    List<Customer> selectFailCustomerByCondition(CustomerQuery customerQuery);

    List<Customer> selectFormalCustomerByCondition(CustomerQuery customerQuery);

    List<Customer> selectLoseCustomerByCondition(CustomerQuery customerQuery);

    List<Customer> selectCustomerStatusByCondition(CustomerQuery customerQuery);

    void updateStatusByPrimaryKey(Customer customer);

    @MapKey("groupType")
    List<Map<String, Object>> countCustomerMakeByEmp(@Param("keyword") String keyword,@Param("dateBegin") String dateBegin,@Param("dateEnd") String dateEnd);

    @MapKey("groupType")
    List<Map<String, Object>> countCustomerMakeByYear(@Param("keyword") String keyword,@Param("dateBegin") String dateBegin,@Param("dateEnd") String dateEnd);

    @MapKey("groupType")
    List<Map<String, Object>> countCustomerMakeByMonth(@Param("keyword") String keyword,@Param("dateBegin") String dateBegin,@Param("dateEnd") String dateEnd);

    @MapKey("groupType")
    List<Map<String, Object>> countCustomerMakeByDay(@Param("keyword") String keyword,@Param("dateBegin") String dateBegin,@Param("dateEnd") String dateEnd);

    /**
     * 修改客户状态
     * @param customerId
     * @param status
     */
    void updateCustomerStatus(@Param("id") Long customerId,@Param("status") Integer status);

    void editSellerId(@Param("customerId") Long customerId,@Param("newSellerId") Long newSellerId);
}